package org.xuan.dubbo.consumer2.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.dubbo.config.annotation.Reference;
 
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.xuan.dubbo.api.entity.User;
import org.xuan.dubbo.api.service.TestService;

@RestController
@RequestMapping("/")
public class TestController {
    @Reference(version = "1.0.0",group="ydq",mock="true",check=false)
    private TestService testService;

    //@PathVariable
    @GetMapping(value="hello")
    @SentinelResource(value = "hello",blockHandler = "deal_hello")
    //@SentinelResource 是对 消费者 压力的熔断 需要 在 sentinel 配置流控
    public String hello(@RequestParam String type) {
        return testService.sayHello(type);
    }

    
    public String deal_hello(String p1, String p2, BlockException exception){
        return "************************deal_testHotKey";
    }
    
    @GetMapping("user")
    public User user() {
    	int i=0;
    	i=i/0;
    	i=0/i;
        return testService.findUser();
    }
}